package com.hongxun.budget.ui.fragment.ys;

import android.widget.TextView;

import com.hongxun.budget.R;
import com.hongxun.budget.greendao.EWorkContentEntityDao;
import com.hongxun.budget.ui.fragment.BaseListFragment;
import com.hongxun.budget.utils.GreenDaoManager;
import com.hongxun.budget.utils.SPUtils;
import com.hongxun.greenentity.ys.EWorkContentEntity;
import com.jessewu.library.SuperAdapter;
import com.jessewu.library.view.ViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 项目内容
 */

public class YsProjectContentFragment extends BaseListFragment {

    List<EWorkContentEntity> datas = new ArrayList<>();
    SuperAdapter<EWorkContentEntity> adapter;

    @Override
    public SuperAdapter getAdapter() {
        return adapter = new SuperAdapter<EWorkContentEntity>(R.layout.content_fragment_project_content) {
            @Override
            public void bindView(ViewHolder viewHolder, EWorkContentEntity d, int i) {
                ((TextView) viewHolder.getView(R.id.content)).setText(d.getWCContent());
            }
        };
    }

    @Override
    public void initView() {
        super.initView();
        datas.addAll(GreenDaoManager.getInstance().getmDaoSession().getEWorkContentEntityDao().queryBuilder().where(
                EWorkContentEntityDao.Properties.PGuid.eq(SPUtils.get(context, "project_ys_guid", "")
                ), EWorkContentEntityDao.Properties.WCDatastate.notEq("删除")
        ).list());
        adapter.setData(datas);
        adapter.setEmptyDataView(R.layout.view_empty);
    }
}
